package com.cws4cloud.cws.mall.xsm.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * @ClassName: EncryptProperties
 * @Description:
 * @Date 2021/6/22 22:37
 */
@Configuration
@ConfigurationProperties(prefix = "cws.encrypt")
public class EncryptProperties {

	private Map<String,Map<String,String>> encrypt;


	private String sid;

	private String publickey;

	private String privatekey;

	private String payid;

	public Map<String, Map<String, String>> getEncrypt() {
		return encrypt;
	}

	public void setEncrypt(Map<String, Map<String, String>> encrypt) {
		this.encrypt = encrypt;
	}

	public String getSid(String orgCode) {
		return Optional.ofNullable(getEncrypt().get(orgCode)).orElse(new HashMap<String, String>(){{
			put("sid", null);
		}}).get("sid");
	}


	public String getPublickey(String orgCode) {
		return Optional.ofNullable(getEncrypt().get(orgCode)).orElse(new HashMap<String, String>(){{
			put("publickey", null);
		}}).get("publickey");
	}


	public String getPrivatekey(String orgCode) {
		return Optional.ofNullable(getEncrypt().get(orgCode)).orElse(new HashMap<String, String>(){{
			put("privatekey", null);
		}}).get("privatekey");
	}


	public String getPayid(String orgCode) {
		return Optional.ofNullable(getEncrypt().get(orgCode)).orElse(new HashMap<String, String>(){{
			put("payid", null);
		}}).get("payid");
	}

}
